/**
 * Copyright (c) 2011 Nokia Corporation.
 */

#ifndef TRANSFERUICLIENTITEM_H
#define TRANSFERUICLIENTITEM_H

// Qt includes
#include <QDeclarativeItem>
#include <QList>

// Harmattan includes
#include <TransferUI/TransferEnums>


namespace TransferUI {

// Forward declarations
class Client;
class Transfer;
class TransferUITransferItem;


class TransferUIClientItem : public QDeclarativeItem
{
    Q_OBJECT
    Q_PROPERTY(bool initialized READ initialized NOTIFY initializedChanged)
    Q_PROPERTY(double progressValueDelta READ progressValueDelta NOTIFY progressValueDeltaChanged)
    Q_PROPERTY(int progressTimeDelta READ progressTimeDelta NOTIFY progressTimeDeltaChanged)

public:
    explicit TransferUIClientItem(QDeclarativeItem *parent = 0);
    virtual ~TransferUIClientItem();

public:
    Client *clientInstance() const;
    bool initialized() const;
    void setProgressValueDelta(double delta);
    double progressValueDelta() const;
    void setProgressTimeDelta(int delta);
    int progressTimeDelta() const;
    Q_INVOKABLE bool isTUIVisible() const;

protected:
    void setInitialized(bool initialized);

public slots:
    bool init();
    bool askForSummaryUpdate();
    TransferUITransferItem *registerTransfer(const QString &name,
                                             /*TransferType*/ int type,
                                             const QString &clientId /* = QString() */); // QML cannot handle method overloading
    bool showUI();
    void removeTransfer(const QString& tid);

signals:
    void initializedChanged(bool initialized);
    void progressValueDeltaChanged(double delta);
    void progressTimeDeltaChanged(int delta);

    // Rerouted signals from the actualy client
    void transferCancelled(Transfer *transfer);
    void transferPaused(Transfer *transfer);
    void errorRepairForTransferRequested(Transfer *transfer);
    void transferStarted(Transfer *transfer);
    void summaryReport(int failed, int active, int pending, int completed);

private: // Data
    Client *m_client; // Owned
    bool m_initialized;
};

} // namespace TransferUI


#endif // TRANSFERUICLIENTITEM_H

// End of file.
